from django.conf.urls import url
from django.urls import path

from HelloWord.settings import MEDIA_ROOT
from Template import views

app_name = 'tmp'
urlpatterns = [
    url(r'HelloTemplate/', views.HelloTemplate),
    url(r'index/', views.index),
    url(r'getstudents/', views.get_students),
    # 模板继承
    url(r'home/', views.home),
    url(r'homes/', views.home_main),
    # url 路由
    # 1、路由中的参数用()进行获取；一个圆括号对应视图函数中的一个参数
    url(r'grades/', views.grades),
    url(r'students/(\d+)', views.students),
    # 位置参数
    url(r'gettime/(\d+)/(\d+)/(\d+)/', views.get_time, name='time'),
    # 关键字参数
    url(r'getdate/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/', views.get_date, name='date'),
    # url 反向解析，上层要设置namespace='tmp';本层设置name
    url(r'learn/', views.learn, name='learn'),
    url(r'resolver/', views.url_resolver, name='resolver'),
    # 解析请求参数
    url(r'^haverequest/', views.have_request),
    # http://127.0.0.1:8000/Template/haverequest/?hobby=coding&hobby=sleeping&hobby=eating
    # 发送一个post请求
    # CSRF验证失败. 请求被中断;临时措施注释# 'django.middleware.csrf.CsrfViewMiddleware',
    url(r'^createstudent/', views.create_student, name='create_student'),
    # 接收post请求
    url(r'^docreatestudent/', views.do_create_student, name='do_create_student'),
    # url Response请求
    url(r'^resp/', views.resp, name='resp'),
    # url 重定向
    url(r'rdirect/', views.rdirect, name='redirect'),
    # 返回json对象
    url(r'resjson/', views.resjson, name='resjson'),
    url(r'setcookie/', views.set_cookie, name='set_cookie'),  # 设置cookie
    url(r'getcookie/', views.get_cookie, name='get_cookie'),  # 获取设置的cookie明文
    # cookie 登录验证实例
    url(r'^login/', views.login, name='login'),
    url(r'^dologin/', views.do_login, name='do_login'),
    url(r'^mine/', views.mine, name='mine'),
    url(r'^dologout/', views.do_logout, name='do_logout'),
    url(r'slogin/', views.slogin, name='slogin'),
    url(r'^smine/', views.smine, name='smine'),
    url(r'^slogout/', views.slogout, name='slogout'),
    # token练习
    url(r'^register/', views.register, name='register'),
    url(r'^studentlogin/', views.sutdent_login, name='student_login'),
    url(r'^studentmine/', views.student_mine, name="student_mine"),
    url(r'^addcustomer/', views.add_customer, name='add_customer'),
    url(r'addgoods/', views.add_goods, name='add_goods'),
    url(r'^addtocart/', views.add_to_cart, name='add_to_cart'),
    url(r'^getgoodslist/(?P<customerid>\d+)/', views.get_goods_list, name='add_goods_list'),
    # 文件上传
    url(r'uploadfile/', views.uploadfile, name='uploadfile'),
    url(r'^imagefield/', views.image_field, name='image_filed'),
    # 用户信息展示
    url(r'^usermine/', views.user_mine, name='user_mine'),
    # 缓存设置/中间件
    url(r'cachenew/', views.cache_new, name='cache_new'),
    url(r'cachenew1/', views.cache_new1, name='cache_new1'),
    # 中间件练习
    url(r'^getphone/', views.get_phone, name='get_phone'),
    url(r'^getticket/', views.get_ticket, name='get_ticket'),
    url(r'^search/', views.search, name='search'),
    # 分页显示
    url(r'^getstudent/',views.get_student,name='get_student'),
    url(r'^getstudentwithpage/',views.get_student_with_page,name='get_student_with_page')
]
